package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.HcChuku;
import com.ruoyi.system.service.IHcChukuService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 医院耗材管理系统Controller
 * 
 * @author ruoyi
 * @date 2023-05-05
 */
@RestController
@RequestMapping("/system/chuku")
public class HcChukuController extends BaseController
{
    @Autowired
    private IHcChukuService hcChukuService;

    /**
     * 查询列表
     */
    @PreAuthorize("@ss.hasPermi('system:chuku:list')")
    @GetMapping("/list")
    public TableDataInfo list(HcChuku hcChuku)
    {
        startPage();
        List<HcChuku> list = hcChukuService.selectHcChukuList(hcChuku);
        return getDataTable(list);
    }

    /**
     * 导出列表
     */
    @PreAuthorize("@ss.hasPermi('system:chuku:export')")
    @Log(title = "", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HcChuku hcChuku)
    {
        List<HcChuku> list = hcChukuService.selectHcChukuList(hcChuku);
        ExcelUtil<HcChuku> util = new ExcelUtil<HcChuku>(HcChuku.class);
        util.exportExcel(response, list, "数据");
    }

    /**
     * 获取医院耗材管理系统详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:chuku:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(hcChukuService.selectHcChukuById(id));
    }

    /**
     * 新增医院耗材管理系统
     */
    @PreAuthorize("@ss.hasPermi('system:chuku:add')")
    @Log(title = "", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HcChuku hcChuku)
    {
        return toAjax(hcChukuService.insertHcChuku(hcChuku));
    }

    /**
     * 修改医院耗材管理系统
     */
    @PreAuthorize("@ss.hasPermi('system:chuku:edit')")
    @Log(title = "", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HcChuku hcChuku)
    {
        return toAjax(hcChukuService.updateHcChuku(hcChuku));
    }

    /**
     * 删除医院耗材管理系统
     */
    @PreAuthorize("@ss.hasPermi('system:chuku:remove')")
    @Log(title = "", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hcChukuService.deleteHcChukuByIds(ids));
    }
}
